package com.thghh.ch5.tree;

/**
 * @author Zhikang.Peng
 * @version 1.0
 * @email thghh@qq.com
 * @date 2020/9/9 17:30
 */
public class BinNodePtr<E> implements BinNode<E> {

    private E element;
    private BinNode left;
    private BinNode right;

    public BinNodePtr() {
        left = right = null;
    }

    public BinNodePtr(E e) {
        left = right = null;
        element = e;
    }

    public BinNodePtr(E element, BinNode left, BinNode right) {
        this.element = element;
        this.left = left;
        this.right = right;
    }

    public E element() {
        return element;
    }

    public E setElement(E e) {
        return element = e;
    }

    public BinNode left() {
        return left;
    }

    public BinNode setLeft(BinNode b) {
        return left = b;
    }

    public BinNode right() {
        return right;
    }

    public BinNode right(BinNode b) {
        return right = b;
    }

    public boolean isLeaf() {
        return left == null && right == null;
    }
}
